#define _CRT_SECURE_NO_WARNINGS 1

class MinStack {
public:
    MinStack() {

    }

    void push(int val) {
        _instack.push_back(val);
        if ((_minstack.size() == 0) || val <= getMin())
        {
            _minstack.push_back(val);
        }
    }

    void pop() {
        int tmp = top();
        _instack.pop_back();
        if (tmp == getMin())
            _minstack.pop_back();
    }

    int top() {
        return _instack.back();
    }

    int getMin() {
        return _minstack.back();
    }

private:
    vector<int> _instack;
    vector<int> _minstack;
};